<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		 <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
		<script type="text/javascript" src="layui1/layui.js" ></script>
		<script src="js/jQuery-2.2.2-min.js"></script>
		<link rel="stylesheet" href="layui1/css/layui.css" />
        <style>
            .layui-form-selectup dl {
                top: 42px;
                bottom: unset;
            }
        </style>
	</head>
	<body>
		  <div class="layui-form-item layui-form-text" style="float: left;">
  
    <div class="layui-input-block">
      <textarea id="sendmoments_content" placeholder="请输入内容" class="layui-textarea" rows="4" cols="80" style="float: left; margin-left:-50px ;margin-top: 30px"></textarea>
    </div>
              <form class="layui-form" action="">

                      <label class="layui-form-label">请选择权限</label>
                      <div class="layui-input-inline">
                          <select name="city" id="permissionnum">

                              <option value="2">所有人可见</option>
                              <option value="1">好友可见</option>
                              <option value="0">自己可见</option>

                          </select>
                      </div>

              </form>
    <div class="layui-upload">
  <button style="float: left; margin-left: 605px; margin-top: -6px; border: 0px;" type="button" class="layui-btn layui-btn-primary" id="test1"><i class="layui-icon layui-icon-camera " style="font-size: 30px;"></i> </button>

  <div class="layui-upload-list" style="border: 0px;">
      <img class="layui-upload-img" id="demo1"  width="120px" height="120px" style="float: left ;margin-left: 330px ;margin-top: -20px">
      <input id="thisimagepath" type="hidden"value=""/>

    <p id="demoText"></p>
  </div>
</div>   
  </div>

	</body>
	<script>
layui.use('upload', function(){
  var $ = layui.jquery
  ,upload = layui.upload;
  
  //普通图片上传
  var uploadInst = upload.render({
    elem: '#test1'
    ,url: 'momentsimage/momentsImageUpdate'
    ,before: function(obj){
      //预读本地文件示例，不支持ie8
      obj.preview(function(index, file, result){
        $('#demo1').attr('src', result); //图片链接（base64）
      });
    }
    ,done: function(res){
        //console.info(res.src);
$("#thisimagepath").val(res.src);
      //如果上传失败
      if(res.code > 0){
        return layer.msg('上传失败');
      }
      //上传成功

    }
    /*,error: function(){
      //演示失败状态，并实现重传
      var demoText = $('#demoText');
      demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
      demoText.find('.demo-reload').on('click', function(){
        uploadInst.upload();
      });
    }*/
  });
   });

layui.use(['form','layer'], function(){
    var form =layui.form,
        layer=layui.layer;
})
/*   子层回调函数 获取图片路径和信息*/
   var callbackdata = function () {
           var data = {
               sendmoments_content: $("#sendmoments_content").val(),
                imagepath:$("#thisimagepath").val(),
               permissionnum:$("#permissionnum").val(),
            };
            return data;
        }

  </script>
</html>
